import type {
  SuggestionDetailResult,
  SuggestionListResult,
  SuggestionRequest,
  SuggestionStatusRequest,
} from '@/api/model/suggestionMode';
import { request } from '@/utils/request';

// API接口定义
const Api = {
  SuggestionList: 'suggestion/list', // 获取建议列表
  SuggestionDetail: 'suggestion', // 获取建议详情
  SuggestionDelete: 'suggestion', // 删除建议
  SuggestionHandle: 'suggestion/handle', // 处理建议
  SuggestionComplete: 'suggestion/complete', // 完成建议
};

/**
 * 获取建议列表
 * @param params 查询参数
 * @returns 建议列表数据
 */
export function getSuggestionList(params: SuggestionRequest) {
  return request.post<SuggestionListResult>({
    url: Api.SuggestionList,
    params,
  });
}

/**
 * 获取建议详情
 * @param id 建议ID
 * @returns 建议详情数据
 */
export function getSuggestionDetail(id: number) {
  return request.get<SuggestionDetailResult>({
    url: `${Api.SuggestionDetail}/${id}`,
  });
}

/**
 * 删除建议
 * @param id 建议ID
 */
export function deleteSuggestion(id: number) {
  return request.delete({
    url: `${Api.SuggestionDelete}/${id}`,
  });
}

/**
 * 处理建议
 * @param data 处理建议的数据
 */
export function handleSuggestion(data: SuggestionStatusRequest) {
  return request.put({
    url: Api.SuggestionHandle,
    data,
  });
}

/**
 * 完成建议
 * @param data 完成建议的数据
 */
export function completeSuggestion(data: SuggestionStatusRequest) {
  return request.put({
    url: Api.SuggestionComplete,
    data,
  });
}
